package com.gisquest.cloud.api;

import com.gisquest.cloud.entity.po.BizLogDbEntity;
import com.gisquest.cloud.entity.vo.RequestEntity;
import com.gisquest.cloud.entity.vo.RestResult;
import com.gisquest.cloud.entity.vo.SysLogVO;
import com.gisquest.cloud.service.DbService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author guowei
 * @Date 2020/6/24 13:50
 * @Description:
 **/
@RestController
@RequestMapping("/db")
@Api(value = "日志存储数据库的API管理",tags = "日志存储数据库的API管理")
public class DbController {

  @Autowired
  DbService dbService;

  /**
   * 添加业务日志信息到db
   * @param bizLogDbEntity
   * @return
   */
  @ApiOperation(value = "添加业务日志信息到db", notes = "add by gw 2020-06-24")
  @PostMapping("/saveBizLogToDb")
  public RestResult<?> saveBizLogToDb(@RequestBody @ApiParam("请求参数对象") BizLogDbEntity bizLogDbEntity){
    return dbService.saveBizLogToDb(bizLogDbEntity);
  }

  /**
   * 从db查询业务日志信息
   * @param requestEntity
   * @return
   */
  @ApiOperation(value = "从db查询业务日志信息", notes = "add by gw 2020-06-24")
  @GetMapping("/getBizLogFromDb")
  public RestResult<?> getBizLogFromDb(@RequestBody @ApiParam("请求参数对象") RequestEntity requestEntity){
    return dbService.getBizLogFromDb(requestEntity);
  }


  /**
   * 添加系统日志信息到db
   * @param sysLogVO
   * @return
   */
  @ApiOperation(value = "添加系统日志信息到db", notes = "add by gw 2020-06-24")
  @PostMapping("/saveSysLogToDb")
  public RestResult<?> saveSysLogToDb(@RequestBody @ApiParam("请求参数对象") SysLogVO sysLogVO){
    return dbService.saveSysLogToDb(sysLogVO);
  }


  /**
   * 从db查询系统日志信息
   * @param sysLogVO
   * @return
   */
  @ApiOperation(value = "从db查询系统日志信息", notes = "add by gw 2020-06-24")
  @GetMapping("/getSysLogFromDb")
  public RestResult<?> getSysLogFromDb(@RequestBody @ApiParam("请求参数对象") SysLogVO sysLogVO){
    return dbService.getSysLogFromDb(sysLogVO);
  }

}
